#include "RenderPack.h"
#include "RenderUnit.h"


namespace Display
{
	RenderPack::RenderPack(void)
	{

	}


	RenderPack::~RenderPack(void)
	{

	}

	RenderPack * RenderPack::Create(ID3D11Device * device)
	{
		RenderPack * pack = new RenderPack();
		pack->SetDevice(device);

		return pack;
	}
	void RenderPack::Destroy(RenderPack * pack)
	{
		if(pack != nullptr)
			delete pack;
	}


	RenderUnit * RenderPack::CreateRenderUnit()
	{
		RenderUnit * unit = RenderUnit::Create(GetDevice());
		units.push_back(unit);

		return unit;
	}
	void RenderPack::DeleteRenderUnit(RenderUnit * unit)
	{
		for(it = units.begin();it != units.end();++it)
		{
			if((*it) == unit)
			{
				RenderUnit::Destroy(unit);
				units.erase(it);
				break;
			}
		}
	}

	RenderUnit * RenderPack::GetRenderUnit(int index)
	{
		if(GetRenderUnitsCount() > index + 1)
			return nullptr;
		else 
			return units[index];
	}
	int RenderPack::GetRenderUnitsCount()
	{
		return units.size();
	}
}